package com.kisszoltan.android.passivity.util;

import java.util.HashSet;
import java.util.Set;

import jxl.Sheet;
import jxl.Workbook;
import android.content.Context;
import android.util.Log;

public class DBService {

    private static final String dataXLS = "test_questions.xls";

    public static String[] categoriesList(Context c) {

        Set<String> ret = new HashSet<String>();

        try {
            Workbook w = Workbook.getWorkbook(c.getAssets().open(dataXLS));
            Sheet s = w.getSheet(0);

            for (int i = 1; i < s.getRows(); i++) {
                String value = s.getCell(0, i).getContents();
                ret.add(c.getString(c.getResources().getIdentifier(value, "string", c.getPackageName())));
                i = i + 1;
            }

            Log.i(Context.ACTIVITY_SERVICE, ret.toString());
        } catch (Exception e) {
            Log.e(Context.ACTIVITY_SERVICE, e.getMessage(), e);
        }

        return ret.toArray(new String[] {});
    }
}
